package com.editso.haier.controller.user;

import com.editso.haier.result.Result;
import com.editso.haier.service.RecommendedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 推荐信息服务
 * */
@RestController
@RequestMapping(path = "/recommended")
public class Recommended {
    private RecommendedService recommendedService;

    @Autowired
    public void setRecommendedService(RecommendedService recommendedService) {
        this.recommendedService = recommendedService;
    }


    /**
     * 获取一组或多组商品信息
      * @param type 位置
     * @param secondary 选项
     * @param groupSize 获取多少个
     * @param size 单个组中最多包含多少
     * @return 成功返回 2000 失败返回失败信息
     */
    @GetMapping
    public Result get(@RequestParam(defaultValue = "main") String type,
                      @RequestParam(defaultValue = "any") String secondary,
                      @RequestParam(defaultValue = "1") Integer groupSize,
                      @RequestParam(defaultValue = "5") Integer size){
        return recommendedService.getRecommended(type, secondary, groupSize, size);
    }


}
